import { Image } from "@tarojs/components";
import ImageConstant from "@/constant/ImageConstant";
import "./index.less";

interface IProps {
  src?: string;
  className?: string;
  onClick?: Function;
  mode?: string;
}

export default function ImageIcon(props: IProps) {
  const { src = "", className, onClick, mode = "aspectFill" } = props;

  const handleClick = () => {
    onClick && onClick();
  };

  return (
    <Image
      src={`${ImageConstant.SERVER_ROOT}/common${src}`}
      className={`icon ${className}`}
      mode={mode as any}
      onClick={handleClick}
    />
  );
}
